import axios from '@/libs/api.request'

export const listDatabook = (wname, bname) => {
  return axios.request({
    url: 'workspaces/' + wname + '/bookshelfs/' + bname + '/databooks/',
    method: 'get'
  })
}

export const addDatabook = (wname, bname, name) => {
  return axios.request({
    url: 'workspaces/' + wname + '/bookshelfs/' + bname + '/databooks/',
    method: 'post',
    data: {
      name
    }
  })
}

export const deleteDatabook = (wname, bname, name) => {
  return axios.request({
    url: 'workspaces/' + wname + '/bookshelfs/' + bname + '/databooks/' + name + '/',
    method: 'delete'
  })
}

export const infoDatabook = (wname, bname, name) => {
  return axios.request({
    url: 'workspaces/' + wname + '/bookshelfs/' + bname + '/databooks/' + name + '/',
    method: 'get'
  })
}

export const saveDatabook = (wname, bname, name, data) => {
  return axios.request({
    url: 'workspaces/' + wname + '/bookshelfs/' + bname + '/databooks/' + name + '/',
    method: 'put',
    data: data
  })
}

export const collectImage = (wname, bname, name, columnKey) => {
  return axios.request({
    url: 'workspaces/' + wname + '/bookshelfs/' + bname + '/databooks/' + name + '/collect-image/' + columnKey + '/',
    method: 'get'
  })
}
